#页面类
from Day16zy.Base import Base
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from time import sleep
class Page(Base):
    #定位器
    search_loc=(By.NAME,'key')
    #页面元素的封装
    #登录
    dl = (By.XPATH,'//*[@id="hp_nfes_accountbar"]/li[1]/div/button/div/span')
    # 勾选协议
    xieyi=(By.XPATH, '//*[@id="bbz_accounts_pc_lg_box"]/div/div/div[1]/div[4]/div/div[1]/label')
    # 输入账号
    username=(By.XPATH,'//*[@id="bbz_accounts_pc_lg_box"]/div/div/div[1]/div[1]/form/dl[1]/dd/input')
    # 输入密码
    passwoed=(By.XPATH,'//*[@id="bbz_accounts_pc_lg_box"]/div/div/div[1]/div[1]/form/dl[2]/dd/input')
    # 点击登录
    button=(By.XPATH, '//*[@id="bbz_accounts_pc_lg_box"]/div/div/div[1]/div[1]/form/dl[3]/dd/input')

    def search(self):
        #登录
        self.click(self.dl)
        sleep(5)
        # 勾选协议
        self.click(self.xieyi)
        sleep(2)
        # 输入账号
        self.send_keys(self.username,'17733058407')
        sleep(2)
        # 输入密码
        self.send_keys(self.passwoed, 'lcf10140910')
        sleep(2)
        #点击登录
        self.click(self.button)
        sleep(10)

    #业务逻辑
    def luoji_jiuxian_01(self):
        self.open_url('https://www.ctrip.com/')
        self.search()
        sleep(5)